package company.kedaxunfei;

import java.util.Scanner;

public class Ke3 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ax = sc.nextInt();
        int ay = sc.nextInt();
        int bx = sc.nextInt();
        int by = sc.nextInt();

        int minX = Math.min(ax, bx);
        int maxX = Math.max(ax, bx);
        int minY = Math.min(ay, by);
        int maxY = Math.max(ay, by);

        int[] xs = new int[2];
        int[] ys = new int[2];
        xs[0] = sc.nextInt();
        ys[0] = sc.nextInt();
        xs[1] = sc.nextInt();
        ys[1] = sc.nextInt();

        if (xs[0]==ax&&ys[0]==ay&&xs[1]==bx&&ys[1]==by)
        {
            System.out.println(-1);
            return;
        }

        int count = 0;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                if (xs[i] >= minX && xs[i] <= maxX && ys[j] >= minY && ys[j] <= maxY)
                    count++;
            }
        }
        if (count == 0 || count == 4)
            System.out.println(-1);
        else
            System.out.println(1);
    }
}
